home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / utilitys / 9 / mastrmnd.bas < prev    next >
Encoding:
BASIC Source File  |  1986-04-04  |  5.8 KB  |  191 lines

  1. 10    ' By David S. Lay  613-824-6405
  2. 12    '
  3. 15    '''''''''''''''''''''''''''''''
  4. 20    title$=" Mastermind "
  5. 30    title$=chr$(32)+chr$(14)+chr$(15)+title$
  6. 40    title$=title$+chr$(14)+chr$(15)+chr$(32)
  7. 50    gosub 60:goto 170
  8. 60    poke systab+24,1
  9. 70    a#=gb
  10. 80    gintin=peek(a#+8)
  11. 90    poke gintin+0,peek(systab+8)
  12. 100   poke gintin+2,2
  13. 110   s#=gintin+4
  14. 120   title$=title$+chr$(0)
  15. 130   poke s#,varptr(title$)
  16. 140   gemsys(105)
  17. 150   poke systab+24,0
  18. 160   return
  19. 170   fullw 2:clearw 2
  20. 180   if peek(systab)=4 then 240
  21. 190   ?:?:?:?
  22. 200   ?"  This program will work only in low resolution."
  23. 210   ?:?"  Please return to the desktop and use the SET PREFERENCES"
  24. 220   ?"  function to select low resolution mode."
  25. 230   x=inp(2):clearw 2:end
  26. 240   gotoxy 0,0
  27. 250   ?:?"I will select up to six coloured pegs
  28. 260   ?"from ten different colours (duplicates"
  29. 270   ?"are possible) and you will have ten"
  30. 280   ?"tries to guess the combination.  Enter"
  31. 290   ?"your guess using the numeric keypad"
  32. 300   ?"(you can change your guess using the"
  33. 310   ?"arrow keys) then press ENTER.  Each"
  34. 320   ?"time you make a guess I will provide"
  35. 330   ?"hints.  For every peg which is the"
  36. 340   ?"right colour and is in the right"
  37. 350   ?"place, I will show a black peg.  For"
  38. 360   ?"every peg of the right colour but"
  39. 370   ?"in the wrong place, I will show a"
  40. 380   ?"white peg."
  41. 390   ?"   Hit Escape to leave the game."
  42. 400   gotoxy 0,17:?"   Select difficulty level (3 to 6)";
  43. 410   x=inp(2)
  44. 420   if x=27 then 620
  45. 430   if x<51 or x>54 goto 410
  46. 440   dl=x-48
  47. 450   gosub colset
  48. 460   randomize 0
  49. 470   gosub setup
  50. 480   gosub in
  51. 490   if fi=0 then 480
  52. 500   tn=tn+1:for i=1 to dl
  53. 510   c=gu(i)
  54. 520   color 1,c,c,1,1
  55. 530   pcircle i*9+18,145-tn*10,4:next
  56. 540   gosub boxoff:bn=1:gosub boxon
  57. 550   gosub check
  58. 560   if nw=dl then 580
  59. 570   if tn<10 then 480
  60. 580   for i=1 to dl:c=gi(i)
  61. 590   color 1,c,c,1,1:pcircle i*9+18,30,4
  62. 600   next
  63. 610   x=inp(2):if x<>27 then tn=0:goto 470
  64. 620   title$="OUTPUT":gosub 60:gosub colset:clearw 2:end
  65. 630   check:nb=0:nw=0
  66. 640   for i=1 to dl
  67. 650   gis(i)=gi(i)
  68. 660   gus(i)=gu(i)
  69. 670   next
  70. 680   for i=1 to dl
  71. 690   if gus(i)=gis(i) then nw=nw+1:gis(i)=0:gus(i)=1
  72. 700   next i
  73. 710   for i=1 to dl:for j=1 to dl
  74. 720   if gus(i)=gis(j) then nb=nb+1:gis(j)=0:gus(i)=1
  75. 730   next j,i:bb=0
  76. 740   color 1,14,14,1,1:if nw=0 then 780
  77. 750   for i=1 to nw
  78. 760   bb=bb+1:pcircle bb*9+78,145-tn*10,3
  79. 770   next i
  80. 780   if nb=0 then 830
  81. 790   color 1,15,15,1,1
  82. 800   for i=1 to nb
  83. 810   bb=bb+1:pcircle bb*9+78,145-tn*10,3
  84. 820   next i
  85. 830   return
  86. 840   in:fi=0:x=inp(2)
  87. 850   if x=27 then 620
  88. 860   if x=205 and bn<dl then gosub boxoff:bn=bn+1:gosub boxon:return
  89. 870   if x=203 and bn>1 then gosub boxoff:bn=bn-1:gosub boxon:return
  90. 880   if x=13 then fi=1:return
  91. 890   if x>57 or x<48 then return
  92. 900   c=x-46
  93. 910   gu(bn)=c
  94. 920   color 1,c,c,1,1: pcircle bn*10+193,30,4
  95. 930   x=205:goto 860
  96. 940   return
  97. 950   boxon:color 1,14,14,1,1:goto 970
  98. 960   boxoff:color 1,12,12,1,1
  99. 970   xp=bn*10+188
  100. 980   linef xp,25,xp,35:linef xp,35,xp+10,35
  101. 990   linef xp+10,35,xp+10,25:linef xp+10,25,xp,25
  102. 1000  return
  103. 1010  setup:
  104. 1020  color 1,7,7,1,1:x1=0:x2=320:y1=11:y2=200
  105. 1030  gosub box
  106. 1040  x1=11:x2=150:y1=32:y2=172:color 1,12,12
  107. 1050  gosub box
  108. 1060  color 1,14,14,1,1
  109. 1070  linef 10,10,150,10:linef 150,10,150,150
  110. 1080  linef 150,150,10,150:linef 10,150,10,10
  111. 1090  color 1,14,14,1,1
  112. 1100  linef 12,12,148,12:linef 148,12,148,148
  113. 1110  linef 148,148,12,148:linef 12,148,12,12
  114. 1120  linef 20,20,20,140
  115. 1130  linef 20,140,140,140
  116. 1140  linef 140,140,140,20
  117. 1150  linef 140,20,20,20
  118. 1160  linef 80,20,80,140
  119. 1170  for i=40 to 130 step 10
  120. 1180  linef 20,i,140,i:next
  121. 1190  for i=1 to dl
  122. 1200  pv=int(rnd*10)+2
  123. 1210  gi(i)=pv
  124. 1220  next
  125. 1230  color 1,14,14,1,1
  126. 1240  for i=27 to dl*9+19 step 9
  127. 1250  pcircle i,30,4:next
  128. 1260  x1=191:x2=266:y1=67:y2=162
  129. 1270  color 1,12,12:gosub box
  130. 1280  color 1,2,2,1,1
  131. 1290  x1=201:y1=152:y2=137:x2=236
  132. 1300  gosub box
  133. 1310  color 1,3,3,1,1
  134. 1320  x1=201:y1=132:y2=117:x2=216
  135. 1330  gosub box
  136. 1340  color 1,4,4,1,1
  137. 1350  x1=221:x2=236:gosub box
  138. 1360  color 1,5,5,1,1
  139. 1370  x1=241:x2=256:gosub box
  140. 1380  color 1,6,6,1,1
  141. 1390  x1=201:y1=112:y2=97:x2=216
  142. 1400  gosub box
  143. 1410  color 1,7,7,1,1
  144. 1420  x1=221:x2=236:gosub box
  145. 1430  color 1,8,8,1,1
  146. 1440  x1=241:x2=256:gosub box
  147. 1450  color 1,9,9,1,1
  148. 1460  x1=201:y1=92:y2=77:x2=216
  149. 1470  gosub box
  150. 1480  color 1,10,10,1,1
  151. 1490  x1=221:x2=236:gosub box
  152. 1500  color 1,11,11,1,1
  153. 1510  x1=241:x2=256:gosub box
  154. 1520  x1=191:x2=266:y1=42:y2=63
  155. 1530  color 1,12,12:gosub box
  156. 1540  bn=1:gosub boxon
  157. 1550  return
  158. 1560  colset:
  159. 1570  poke contrl, 14:poke contrl+2,0
  160. 1580  poke contrl+6,4
  161. 1590  for colour=0 to 15:read r,g,b
  162. 1600  redlev=r*1000/7
  163. 1610  grnlev=g*1000/7
  164. 1620  blulev=b*1000/7
  165. 1630  poke intin, colour
  166. 1640  poke intin+2, redlev
  167. 1650  poke intin+4, grnlev
  168. 1660  poke intin+6, blulev
  169. 1670  vdisys(1)
  170. 1680  next colour:return
  171. 1690  data 0,5,0,0,5,0,7,0,0,0,7,0
  172. 1700  data 0,0,7,0,0,3,5,2,0,0,5,0
  173. 1710  data 7,7,0,7,0,7,0,7,7,0,5,5
  174. 1720  data 5,5,5,5,0,5,0,0,0,7,7,7
  175. 1730  ' normal colours
  176. 1740  data 7,7,7,0,0,0,7,0,0,0,7,0,0,0,7
  177. 1750  data 0,0,5,5,2,0,0,5,0,5,5,5
  178. 1760  data 2,2,2,0,7,7,0,5,5,7,0,7
  179. 1770  data 5,0,5,7,7,0,5,5,0
  180. 1780  box: rem VDI box draw routine
  181. 1790  poke contrl,11
  182. 1800  poke contrl+2,2
  183. 1810  poke contrl+6,0
  184. 1820  poke contrl+10,1
  185. 1830  poke ptsin,x1
  186. 1840  poke ptsin+2,y1
  187. 1850  poke ptsin+4,x2
  188. 1860  poke ptsin+6,y2
  189. 1870  vdisys(1)
  190. 1880  return
  191. əəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəə